// @ts-nocheck
/**
 * @Date: 2022-03-10 20:15:46
 * @LastEditors: sailornpg
 * @LastEditTime: 2022-03-13 18:39:06
 * @FilePath: \zhihuReal\routes\answer.js
 * @Description: 答案路由
 */
const router = require('koa-router')()
router.prefix('/questions/:questionId/answers')
const {
    auth
} = require('../middlewares/auth')
//控制器
const {
    answerList,
    oneAnswer,
    createAnswer,
    updateAnswer,
    removeAnswer,
} = require('../controllers/answersCtl')
const {
    cheackAnswerExist,
    cheackAnswesOwner
} = require('../middlewares/cheack')
//获取答案列表
router.get('/', answerList)
//获取单个答案
router.get('/:id', cheackAnswerExist, oneAnswer)
//创建答案
router.post('/', auth, createAnswer)
//更新答案
router.patch('/:id', auth, cheackAnswerExist, cheackAnswesOwner, updateAnswer)
//删除答案
router.delete('/:id', auth, cheackAnswerExist, cheackAnswesOwner, removeAnswer)
module.exports = router